package org.example.springioc01.config;


import org.example.springioc01.dao.MyDataSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;

//@Profile({"dev"})
@Configuration
public class DataSourceConfig {

    @Profile({"dev"})
    @Bean
    public MyDataSource dev(){
        MyDataSource myDataSource = new MyDataSource();
        myDataSource.setUrl("dev");
        myDataSource.setUsername("dev_use");
        myDataSource.setPassword("dev_pas");
        return myDataSource;
    }

    @Profile({"prod"})
    @Bean
    public MyDataSource prod(){
        MyDataSource myDataSource = new MyDataSource();
        myDataSource.setUrl("prod");
        myDataSource.setUsername("prod_use");
        myDataSource.setPassword("prod_pas");
        return myDataSource;
    }

    @Profile({"test","default"})
    @Bean
    public MyDataSource test(){
        MyDataSource myDataSource = new MyDataSource();
        myDataSource.setUrl("test");
        myDataSource.setUsername("test_use");
        myDataSource.setPassword("test_pas");
        return myDataSource;
    }
}
